package pl.softech.gpw.candles.patterns.impl;

import pl.softech.gpw.candles.Candle;
import pl.softech.gpw.candles.patterns.ICandlePattern;
import pl.softech.gpw.model.FInstrument;

/**
 * http://www.fxwords.com/b/bullish-abandoned-baby-candlestick.html 
 * 
 * • Day-one is a red day continuing an established bear trend.
 * • Day-two is a doji whose shadows trades below day-ones close.
 * • Day-three is a blue day that opens and trades above with little or no overlapping shadows
 */
public class BullishAbandonedBaby implements ICandlePattern {

    @Override
    public Type getType() {
        return Type.REVERSAL;
    }

    @Override
    public int getBarCount() {
        return 3;
    }

    @Override
    public Direction getDirection() {
        return Direction.BULLISH;
    }

    @Override
    public Reliability getReliability() {
        return Reliability.STRONG;
    }

    @Override
    public boolean test(FInstrument[] finstruments) {
        
        Candle[] candlesticks = Candle.create(finstruments, getBarCount());
        
        if(candlesticks[0].isBlack()) {
            
            if(candlesticks[1].getBodyLen() == 0) {
                
                if(candlesticks[0].instrument().getClose() > candlesticks[1].instrument().getLow()) {
                    
                    if(candlesticks[2].isWhite() && candlesticks[2].isAbove(candlesticks[1])) {
                        return true;
                    } 
                    
                }
                
            }
            
        }
        
        return false;
    }

}
